// 引入mongoose接口
const mongoose = require("mongoose");
const { indent } = require("./data/indent");
// 初始化model
const schema = new mongoose.Schema({
    userId: String,
    information: Array,
    total: String,
    time: String,
    state:String
});
// 添加并定义model
const orderModel = mongoose.model("order", schema, "order")

mongoose.connect(
    "mongodb://tangzhenhua:Lovo123456@182.92.214.223:8084/heshumiao_project3",

    {
        useNewUrlParser: true,
        useUnifiedTopology: true,
        auth: { authSource: "admin" }
    }, 
    async () => {
        // 当连接成功后触发
        // 创建电影数据 一个（对象）或多个（数组）
        console.log(indent);
        await orderModel.create(indent);
        
      }

);

module.exports = { orderModel };